<?php

namespace zhuli\web;

class Request
{
	public function get($name = null, $default = null )
	{
		if (!empty($name)) {
			return $_GET[$name];
		}
		return $defaults;

	}

	public function post($name = null, $defaults = null)
	{
		if (!empty($name)) {
			return $_POST[$name];
		}
		return $defaults;
	}

	public function server($name = null, $defaults = null)
	{
		if (!empty($name)) {
			return $_SERVER[$name];
		}
		return $defaults;


	}

	public function getPathInfo()
	{
		return $_SERVER['PATH_INFO'];
	}

	public function getControllerId()
	{
		$pathinfo = $this->getPathInfo();
		$newpathinfo = explode('/',trim($pathinfo,'/'));
		return $newpathinfo[0];

	}

	public function getActionId()
	{
		$pathinfo = $this->getPathInfo();
		$newpathinfo = explode('/',trim($pathinfo,'/'));
		return $newpathinfo[1];
	}
}